package com.title7;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Scanner;

/**
 * @Author milian
 * @Date 2021/8/2 0002 21:28
 */
public class title7 {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入：");
        String s = sc.nextLine();
        String[] split = s.split("");
        int count = 1;
        FileOutputStream fos = new FileOutputStream("D:\\count.txt");
        for (int i = 0; i < split.length - 1; i++) {
            if (split[i].equals(split[i + 1])) {
                count++;
                if (i==(split.length)-2){
                    fos.write((count + split[i]).getBytes());
                }
            } else {
                fos.write((count + split[i]).getBytes());
                count = 1;
            }
        }
        if(!split[split.length-2].equals(split[split.length-1])){
            fos.write((1 + split[split.length-1]).getBytes());
        }
        fos.close();
    }
}
